/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.visualjavafxgui.editor.text;

import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.text.Document;
import org.netbeans.core.spi.multiview.CloseOperationState;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.MultiViewElementCallback;
import org.openide.text.CloneableEditor;
import org.openide.text.DataEditorSupport;
import org.openide.text.NbDocument;

/**
 *
 * @author psychollek
 */
public class VisualJavaFxTextEditor extends CloneableEditor implements MultiViewElement{
    private JComponent toolbar = null;
    private MultiViewElementCallback callback = null;

    public VisualJavaFxTextEditor(DataEditorSupport es){
        super(es);
    }

    @Override
    public JComponent getVisualRepresentation() {
        return this;
    }

    @Override
    public JComponent getToolbarRepresentation() {
        if (toolbar == null) {
            JEditorPane tmpPane = this.pane;
            if (tmpPane != null) {
                Document doc = tmpPane.getDocument();
                if (doc instanceof NbDocument.CustomToolbar) {
                    toolbar = ((NbDocument.CustomToolbar)doc).createToolbar(tmpPane);
                }
            }
            if (toolbar == null) {
                //attempt to create own toolbar?
                toolbar = new JPanel();
            }
        }
        return toolbar;
    }

    @Override
    public void setMultiViewCallback(MultiViewElementCallback val) {
        this.callback = val;
    }


    @Override
    public CloseOperationState canCloseElement() {
        return CloseOperationState.STATE_OK;
    }

    @Override
    public void componentDeactivated(){
        super.componentDeactivated();
    }

    @Override
    public void componentActivated(){
        super.componentActivated();
    }

    @Override
    public void componentHidden(){
        super.componentHidden();
    }

    @Override
    public void componentShowing(){
        super.componentShowing();
    }

    @Override
    public void componentClosed(){
        super.componentClosed();
    }
    
    @Override
    public void componentOpened(){
        super.componentOpened();
    }

}
